import {AbstractReducerGroup} from '../storeBase';
import {SET_TITLE} from "./actions";

class UiReducer extends AbstractReducerGroup {
    state = {
        title: 'SUPER_CTL',
        showTab: true,
    };
    handlers = {};

    constructor() {
        super();
        this.handlers[SET_TITLE] = action => {
            this.state.title = action.title;
            return this.state;
        };
    }

    getState() {
        return this.state;
    }

    handleAction(type, action) {
        if (!(type in this.handlers)) {
            console.warn('cant find reducer', action);
            return;
        }
        return this.handlers[type](action);
    }

    getName() {
        return 'ui';
    }
}

export default UiReducer;